﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using personalplaner.common.mvvm;
using System.Windows;

namespace personalplaner.gui.common.viewmodels.models
{
	public class InitWizardYearModel : BaseModel
	{
		#region Properties

		IList<int> _years;
		public IList<int> Years
		{
			get
			{
				if (_years == null)
				{
					_years = new List<int>();

					int maxJahr = DateTime.Now.Year;
					for (int cnt = 0; cnt < 10; cnt++)
					{
						_years.Add(maxJahr + cnt);
					}

					SelectedYear = DateTime.Now.Year;
				}
				return _years;
			}
		}

		int _selectedYear;
		public int SelectedYear
		{
			get
			{
				return _selectedYear;
			}
			set
			{
				_selectedYear = value;
				RaisePropertyChanged("SelectedYear");

				RaisePropertyChanged("Von");
				RaisePropertyChanged("Bis");
			}
		}

		public DateTime? Von
		{
			get
			{
				if (SelectedYear < 1000)
					return null;
				return new DateTime(SelectedYear, 1, 1);
			}
		}

		public DateTime? Bis
		{
			get
			{
				if (SelectedYear < 1000)
					return null;
				return new DateTime(SelectedYear, 12, 31);
			}
		}

		#endregion
	}
}
